from data_generation import *
import matplotlib.pyplot as plt
import numpy as np
K=4
N=1000
I=30
item_para = ItemPara(I)
gener = StudentPara(N)
ability = gener.mul_ability([0,0],[[1,0.25],[0.25,0.25]])
# sun_theta= gener.sun_ability(ability[:,0],np.random.random(4),1)
att = gener.get_att(ability[:,0],np.repeat(1.5,K),np.linspace(-1,0.5,4))
sun_tau= gener.sun_ability(ability[:,1],np.random.random(4),0.25)
# print(np.nanvar(sun_theta))
# print(np.exp(ability))
s_mean = 0.1
g_mean = 0.1
beta_i_mean,delta_i_mean = item_para.s_g_re_para(s_mean,g_mean)
item_parameter = np.random.multivariate_normal([delta_i_mean,beta_i_mean,4],[[1,-0.8,-0.25],
                                                                        [-0.8,1,0.15],
                                                                        [-0.25,0.15,0.25]],size=(I))
beta_i = item_parameter[:,1]
delta_i = item_parameter[:,0]
resp,_ = item_para.get_dina_ra(att,beta_i,delta_i,return_possibility=True)
_,omega = item_para.rt_para([4,0.25],[2,0.25])
rt = item_para.get_rt(item_parameter[:,2],omega,sun_tau)
x,y = np.nanmean(resp),np.nanmean(rt)
# print(np.nanmean(resp),np.nanmean(_))
# print(np.nanmean(rt<3.3))
# print(a,b,c)
# print(xi,omega)
ra,rt,flag_mat = item_para.backward_convert(resp,rt,3800,0.25,2,0.25)
plt.hist(np.log(rt.flatten()),bins=100)
# plt.hist(np.exp(rt.flatten()),bins=100)
plt.show()